package DS0423;

public class text {

    public static void main(String[] args){
        int[] arr = fun();
        reverseaff(arr);
        if(palindrome(arr)){
            fun();
            System.out.print("是回文");
        }
        else{
            fun();
            System.out.println("不是回文");
        }

    }

    private static int[] fun() {
        int[] ss={1,2,3,4,5,6};
        return ss;
    }

    private static boolean palindrome(int[] arr) {
        NodeStack nodeStack = new NodeStack();
        for(int i=0;i<arr.length;i++){
            nodeStack.push(arr[i]);
        }

        for(int i=0;i<arr.length;i++){
            int a = nodeStack.top();
            int b = arr[i];
            if(a!=b){
                return false;
            }
            else {
                nodeStack.pop();
            }
        }
        return true;
    }

    private static void reverseaff(int[] arr) {
        NodeStack nodeStack = new NodeStack();
        for(int i=0;i<arr.length;i++){
            nodeStack.push(arr[i]);
        }

        for(int i=0;i<arr.length;i++){
            arr[i] = nodeStack.top();
            nodeStack.pop();
            System.out.print(arr[i]+"  ");
        }
        System.out.println();
    }


}
